
library(testthat)
library(blma)
library(tictoc)
library(parallel)

cores <- detectCores()

test_that('comCrime produces correct results robust_bayarri2', {
	set.seed(2019)
    comCrime <- get_comCrime()
    vy <- comCrime$vy
    mX <- comCrime$mX
    tic('comCrime produces correct results robust_bayarri2')
    result <- sampler(100000, vy, mX, prior='robust_bayarri2', modelprior='uniform', cores=cores)
    toc()
    expect_equal(result$vinclusion_prob, 
c(
0.9554700000000000,0.8661799999999999,0.2813900000000000,0.8647899999999999,
0.2527000000000000,0.6528700000000000,0.2293300000000000,0.3967100000000000,
0.2578200000000000,0.5439900000000000,0.4455400000000000,0.4116500000000000,
0.2351300000000000,0.2767100000000000,0.1504300000000000,0.1651200000000000,
0.2408900000000000,0.2209300000000000,0.3517600000000000,0.1973300000000000,
0.3427100000000000,0.2852600000000000,0.3645400000000000,0.2494100000000000,
0.2316100000000000,0.1845300000000000,0.2582100000000000,0.1981300000000000,
0.4883500000000000,0.2504300000000000,0.5685000000000000,0.1926200000000000,
0.1897200000000000,0.2326200000000000,0.3592300000000000,0.1994300000000000,
0.2151400000000000,0.2157300000000000,0.2020700000000000,0.8108300000000001,
0.3170800000000000,0.2236800000000000,0.3817900000000000,0.6190700000000000,
0.2907700000000000,0.4846300000000000,0.1767800000000000,0.1798500000000000,
0.8657800000000000,0.9684400000000000,0.9663100000000000,0.1731900000000000,
0.2431300000000000,0.2863100000000000,0.6275200000000000,0.1957300000000000,
0.2705200000000000,0.2367700000000000,0.2185800000000000,0.3319600000000000,
0.2047300000000000,0.3955600000000000,0.2993500000000000,0.3499500000000000,
0.4113700000000000,0.3822200000000000,0.3805300000000000,0.7270000000000000,
0.2276700000000000,0.1531400000000000,0.9429600000000000,0.2735100000000000,
0.3645800000000000,0.1750300000000000,0.2596000000000000,0.1713700000000000,
0.2358200000000000,0.3783900000000000,0.3987100000000000,0.3010400000000000,
0.3285000000000000,0.1902900000000000,0.2149000000000000,0.5373500000000000,
0.3462000000000000,0.1586900000000000,0.7538100000000000,0.2026600000000000,
0.3790000000000000,0.6165400000000000,0.1727600000000000,0.1965600000000000,
0.8648000000000000,0.2292200000000000,0.2062100000000000,0.1653000000000000,
0.1552200000000000,0.1549100000000000,0.9502100000000000
)
, tolerance = 1e-8)
})